﻿using System;
using System.Drawing;

namespace MDAControlsFramework.Helpers {
	public class MDASize: ICloneable {
		private MDAValue _width = new MDAValue();
		private MDAValue _height = new MDAValue();

		public MDASize() {
		}

		public MDASize(string width, string height) {
			_width = new MDAValue(width);
			_height = new MDAValue(height);
		}

		public MDASize(MDAValue width, MDAValue height) {
			_width = width;
			_height = height;
		}

		public object Clone() {
			return new MDASize(_width.Clone() as MDAValue, _height.Clone() as MDAValue);
		}

		public void Measure() {
			_width.Measure(MDASettings.screen.Width);
			_height.Measure(MDASettings.screen.Height);
		}

		public Size Size() {
			return new Size(_width.ComputedValue, _width.ComputedValue);
		}

		public int Width {
			get {
				return _width.ComputedValue;
			}
			set {
				_width.SetValue(value);
			}
		}

		public int Height {
			get {
				return _height.ComputedValue;
			}
			set {
				_height.SetValue(value);
			}
		}

		public int X {
			get {
				return _width.ComputedValue;
			}
			set {
				_width.SetValue(value);
			}
		}

		public int Y {
			get {
				return _height.ComputedValue;
			}
			set {
				_height.SetValue(value);
			}
		}

		public void setWidth(string value) {
			_width.SetValue(value);
		}

		public void setHeight(string value) {
			_height.SetValue(value);
		}

		public override bool Equals(System.Object obj) {
			// If parameter is null return false.
			if (obj == null) {
				return false;
			}

			if (obj is Point) {
				Point p = (Point)obj;
				return (p.X == this.X) && (p.Y == this.Y);
			}

			return false;
		}

		public bool Equals(Point obj) {
			return (obj.X == this.X) && (obj.Y == this.Y);
		}

		public override int GetHashCode() {
			return base.GetHashCode();
		}

		public override string ToString() {
			return "[" + _width + ", " + _height + "]";
		}

		public string ToString(bool isSize) {
			if (isSize) {
				return this.ToString();
			} else {
				return "(" + _width + ", " + _height + ")";
			}
		}

	}
}